%%One Player -- linear system with Kalman filter
function ex_LinSys
help place;clc;

A=[2];
B=[1];
C=[1];
D=[0];
Q=[0.01];
R=[0.01];
X0=[10];
Y0=X0;
U0=[1];
P0=[1];
Poles=[0.5];
max_step=100;

P1=newplayer(...
'step_func','LinSys_step',...
'A',A,...
'B',B,...
'C',C,...
'D',D,...
'Q',Q,...
'R',R,...
'X',X0,...
'Y',Y0,...
'U',U0,...
'Poles',Poles,...
'P_est',P0,...
'X_est',X0,...
'X_pre',X0,...
'Y_pre',Y0,...
'X_err',X0-X0,...
'Y_err',Y0-Y0...
)

P1.X_err=P1.X_est-P1.X;
P1.Y_err=P1.Y_pre-P1.Y;
P1.Vars=[P1.X;P1.Y;P1.X_est;P1.Y_pre;P1.P_est]';


G=newgame({P1},...
'pause','pause(G.h)',...
'draw',2,...
'max_step',max_step,...
'axis',[0,max_step,-10,10]...
)
G.plot_labels={'X','Y','X_{est}','Y_{pre}','P_{est}'}
G.plot_components=[1,2;3,4];

G=simgame(G)
